<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>局部组件</title>
    <script src="js/vue.js"></script>
    <style>
        .templateStyle{
            border: 1px dashed #000;
            border-radius: 15px;
            padding: 10px;
            width: 200px;
            height: 160px;
            text-align: center;
            float: left;
            margin-right: 50px;
            margin-bottom: 50px;
            box-shadow:10px 10px 5px #888888;
            background-image: linear-gradient(to bottom right, rgb(0, 38, 255), rgb(51, 255, 0));
        }
        .templateStyle2{
            border: 1px dashed #000;
            border-radius: 15px;
            padding: 10px;
            width: 200px;
            height: 180px;
            text-align: center;
            float: left;
            margin-right: 50px;
            margin-bottom: 50px;
            box-shadow:10px 10px 5px #888888;
            background-image: linear-gradient(to bottom right, rgb(0, 38, 255), rgb(51, 255, 0));
        }
    </style>
</head>
<body>
    <template id="t1">
        <div class="templateStyle">
            <h3>润物无声</h3> 
            <h4>只做增强不做改变，引入它不会对现有工程产生影响，如丝般顺滑</h4>
        </div>
    </template>
    <template id="t2">
        <div class="templateStyle2">
            <div>
                <img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2342083191,4139347491&fm=26&gp=0.jpg" width="180p" height="160px">
            </div>
            <div>
                <span style="font-weight: bold;">{{describle}}</span>
            </div>
        </div>
    </template>
    <div id="app1" style="width: 1100px;margin: 50px auto;">
        <div>
            <test1></test1>
            <test1></test1>
            <test1></test1>
            <test1></test1>
        </div>
        <div  style="clear: both;">
            <imgitem></imgitem>
            <imgitem></imgitem>
            <imgitem></imgitem>
            <imgitem></imgitem>
        </div>
    </div>
    <div id="app2" style="width: 1100px;margin: 50px auto;">
        <test1></test1>
        <test1></test1>
        <test1></test1>
        <test1></test1>
    </div>
    
</body>
</html>
<script>
    var vm = new Vue({
        el:'#app1',
        components:{//定义局部组件的
            'test1':{
                template:'#t1'  //组件的定义和调用（template属性中设置html代码）
            },
            'imgitem':{
                template:'#t2',
                data:function() {
                    return {
                        describle:'小哈哈',
                    }
                },
            }
        }
    })
    var vm2 = new Vue({
        el:'#app2'
    })
</script>